﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LTJ.Common;
using LTJ.FrameWork;
using LTJ.Entity;
using System.Data;


namespace uswinweb.admin
{
    public partial class routesList_update : AdminPage
    {
        public int routID = SASRequest.GetInt("rid", 0);
        public RouteInfo rInfo = new RouteInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            rInfo = Routes.GetRouteByID(routID);
            if (SASRequest.IsPost())
            {
                UpdateRoutes();
            }
        }
        protected void UpdateRoutes()
        {

            string routesCode = SASRequest.GetFormString("routes_hidd_luffy");
            string shipcompCode = SASRequest.GetFormString("shipcomp_hidd_luffy");
            rInfo.bcode = shipcompCode;
            rInfo.tcode = routesCode;
            int msg = Routes.UpdateRoute(rInfo);
            if (msg > 0)
            {
                base.RegisterStartupScript("PAGE", "parent.document.getElementById('reclick').click();parent.Lightview.hide();");
            }
            else
            {
                if (msg == -1)
                {
                    base.RegisterStartupScript("PAGETEMPLATE", "此航线已存在！");
                }
                base.RegisterStartupScript("PAGETEMPLATE", "航线修改失败!");
            }
        }
        public string GetName(string pcode, string type)
        {
            string msg = "&nbsp;";
            string strWhere = " code='" + type.Trim() + "' and tcode='" + pcode.Trim() + "' ";
            BaseDataInfo binfo = BaseDatas.GetBaseDataByStr(strWhere);
            if (binfo != null)
            {
                msg = binfo.name;
            }
            return msg;
        }
    }
}